package caiziyou.com.designpattern.principle.singleresponbility;

/**
 * 设计模式设计原则之单一职责原则
 * 
 * @author Administrator
 *
 */
public class SingleResponsibility3 {
	public static void main(String[] args) {
		Vehicle2 vehicle = new Vehicle2();
		vehicle.run("自行车");
		vehicle.run("汽车");

		vehicle.runAir("飞机");
		vehicle.runWater("轮船");
	}
}

/**
 * 1.没有对类做大的修改，只是增加了方法
 * 2.虽然在类级别上没有做单一原则，但是在方法上遵守了单一原则
 */
class Vehicle2 {
	public void run(String vehicle) {
		System.out.println(vehicle + "在公路上跑。。。");
	}

	public void runAir(String vehicle) {
		System.out.println(vehicle + "在天上飞。。。");
	}

	public void runWater(String vehicle) {
		System.out.println(vehicle + "在水中游。。。");
	}
}
